home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / utilities / disk / genml13.lha / GenML.c next >
Encoding:
C/C++ Source or Header  |  1994-09-26  |  6.1 KB  |  276 lines

  1. /*    GenML
  2.  
  3.     Outils de génération d'entrée de MountList.
  4.  
  5.     Création:        Jean-Michel Bezeau    -    1 avril 1991
  6.     Modification:    Jean-Michel Bezeau    -    21 juin 1991
  7.         ajout du support de 2.0 et correction d'un petit bug
  8.         On peux maintenant passer un nom contenant le ":"
  9.  
  10.     Modification:    Jean-Michel Bezeau    -    26 septembre 1994
  11.         Recompilation avec SAS/C
  12.  
  13. */
  14.  
  15. #include <exec/types.h>
  16. #include <proto/exec.h>
  17.  
  18. #include <libraries/dos.h>
  19. #include <libraries/dosextens.h>
  20. #include <libraries/filehandler.h>
  21. #include <proto/dos.h>
  22.  
  23. #include <string.h>
  24. #include <stdio.h>
  25.  
  26. char *version    = "\0$VER: GenML 1.3 (26-9-94)";
  27. char *createur    = "GenML © Jean-Michel Bezeau 1991,1994";
  28. char *format    = "FORMAT: %s HANDLER/A\n";
  29.  
  30. /* ------------------------------------------------------------------------    */
  31. /*
  32.  *  Convert a BSTR into a normal string.. copying the string into buf.
  33.  */
  34.  
  35. void btos (UBYTE *buf, BSTR bstr)
  36. {
  37. register UBYTE *str;
  38.     str = (UBYTE*) BADDR (bstr);
  39.     strncpy (buf, str+1, *str);
  40.     buf[*str] = 0;
  41.  
  42.     return;
  43. }
  44.  
  45. /* ------------------------------------------------------------------------    */
  46. void AffDosList (ULONG type)
  47. {
  48. BPTR         bdev;
  49. struct DosInfo    *dinfo;
  50. struct RootNode    *root;
  51. struct DosList    *dosl;
  52. char         nom[256];
  53.  
  54.     root    = (struct RootNode    *) DOSBase->dl_Root;
  55.     dinfo     = (struct DosInfo    *) BADDR(root->rn_Info);
  56.     bdev     = (BPTR) dinfo->di_DevInfo;
  57.  
  58.     while ( dosl = (struct DosList*) BADDR(bdev) )
  59.     {
  60.         btos (nom, dosl->dol_Name);
  61.  
  62.         if (dosl->dol_Type == type)
  63.             printf ("\t%s\n", nom);
  64.  
  65.         bdev = dosl->dol_Next;
  66.     }
  67.  
  68.     printf ("\n");
  69.  
  70.     return;
  71. }
  72.  
  73. /* ------------------------------------------------------------------------    */
  74. struct DosList    *ChercheDosList (char *nomdev, ULONG type)
  75. {
  76. BPTR         bdev;
  77. struct DosInfo    *dinfo;
  78. struct RootNode    *root;
  79. struct DosList    *dosl;
  80. struct DosList    *dlist;
  81. char         nom[256];
  82.  
  83.     strtok(nomdev, ":");    // Va remplacer le : par \0 si nécessaire
  84.  
  85.     if (DOSBase->dl_lib.lib_Version >= 36)
  86.     {
  87.         // 2.0 friendly
  88.         dlist = LockDosList (LDF_DEVICES|LDF_READ);
  89.         dosl = FindDosEntry (dlist, nomdev, LDF_DEVICES);
  90.         UnLockDosList (LDF_DEVICES|LDF_READ);
  91.     }
  92.     else
  93.     {
  94.         Forbid();
  95.         root    = (struct RootNode    *) DOSBase->dl_Root;
  96.         dinfo     = (struct DosInfo    *) BADDR(root->rn_Info);
  97.         bdev     = (BPTR) dinfo->di_DevInfo;
  98.  
  99.         while ( dosl = (struct DosList*) BADDR(bdev) )
  100.         {
  101.             btos (nom, dosl->dol_Name);
  102.  
  103.             if (dosl->dol_Type == type)
  104.                 if (stricmp (nom, nomdev) == NULL)
  105.                     break;
  106.  
  107.             bdev = dosl->dol_Next;
  108.         }
  109.         Permit ();
  110.         if (dosl->dol_Type != DLT_DEVICE)
  111.             dosl = NULL;
  112.     }
  113.  
  114.     return dosl;
  115. }
  116.  
  117. /* ------------------------------------------------------------------------    */
  118. void AfficheMountList (struct DosList *dosl)
  119. {
  120. struct FileSysStartupMsg *fssm;
  121. struct DosEnvec            *denv;
  122. BOOL    fs;
  123. char    chaine[256];
  124.  
  125.     fssm = BADDR(dosl->dol_misc.dol_handler.dol_Startup);
  126.  
  127.     /* On commence l'affichage des données    */
  128.     btos(chaine, dosl->dol_Name);
  129.     printf ("%s:\n", chaine);
  130.  
  131.     if (((UBYTE*)fssm)[0] == '\0' && fssm != NULL)
  132.     {
  133.         btos(chaine, fssm->fssm_Device);
  134.         printf ("\tDevice = %s\n", chaine);
  135.         printf ("\tUnit = %d\n", fssm->fssm_Unit);
  136.  
  137.         btos(chaine, dosl->dol_misc.dol_handler.dol_Handler);
  138.         if (chaine[0])
  139.             printf ("\tFileSystem = %s\n", chaine);
  140.         fs = TRUE;
  141.         denv = BADDR(fssm->fssm_Environ);
  142.     }
  143.     else
  144.     {
  145.         btos(chaine, dosl->dol_misc.dol_handler.dol_Handler);
  146.         if (chaine[0])
  147.             printf ("\tHandler = %s\n", chaine);
  148.         fs = FALSE;
  149.     }
  150.  
  151.     printf ("\tPriority = %d\n", dosl->dol_misc.dol_handler.dol_Priority);
  152.  
  153.     printf ("\tStackSize = %d\n", dosl->dol_misc.dol_handler.dol_StackSize);
  154.  
  155.     if (dosl->dol_misc.dol_handler.dol_GlobVec)
  156.         printf ("\tGlobVec = %d\n", dosl->dol_misc.dol_handler.dol_GlobVec);
  157.  
  158.     if (dosl->dol_misc.dol_handler.dol_Startup && fs)
  159.     {
  160.         btos (chaine, dosl->dol_misc.dol_handler.dol_Startup);
  161.         if (strlen(chaine) > 0)
  162.             printf ("\tStartup = \"%s\"\n", chaine);
  163.     }
  164.  
  165.     if (fs)
  166.     {
  167.         if (denv->de_TableSize >= DE_SIZEBLOCK)
  168.         {
  169.             /* Rien pour le moment!    = 128    */
  170.         }
  171.         if (denv->de_TableSize >= DE_SECORG)
  172.         {
  173.             /* Rien pour le moment! = 0        */
  174.         }
  175.         if (denv->de_TableSize >= DE_NUMHEADS)
  176.         {
  177.             printf ("\tSurfaces = %d\n", denv->de_Surfaces);
  178.         }
  179.         if (denv->de_TableSize >= DE_SECSPERBLK)
  180.         {
  181.             /* Rien pour le moment! = 1        */
  182.         }
  183.         if (denv->de_TableSize >= DE_BLKSPERTRACK)
  184.         {
  185.             printf ("\tBlocksPerTrack = %d\n", denv->de_BlocksPerTrack);
  186.         }
  187.         if (denv->de_TableSize >= DE_RESERVEDBLKS)
  188.         {
  189.             printf ("\tReserved = %d\n", denv->de_Reserved);
  190.         }
  191.         if (denv->de_TableSize >= DE_PREFAC)
  192.         {
  193.             printf ("\tPreAlloc = %d\n", denv->de_PreAlloc);
  194.         }
  195.         if (denv->de_TableSize >= DE_INTERLEAVE)
  196.         {
  197.             printf ("\tInterleave = %d\n", denv->de_Interleave);
  198.         }
  199.         if (denv->de_TableSize >= DE_LOWCYL)
  200.         {
  201.             printf ("\tLowCyl = %d ;", denv->de_LowCyl);
  202.         }
  203.         if (denv->de_TableSize >= DE_UPPERCYL)
  204.         {
  205.             printf ("\tHighCyl = %d\n", denv->de_HighCyl);
  206.         }
  207.         if (denv->de_TableSize >= DE_NUMBUFFERS)
  208.         {
  209.             printf ("\tBuffers = %d\n", denv->de_NumBuffers);
  210.         }
  211.         if (denv->de_TableSize >= DE_BUFMEMTYPE)
  212.         {
  213.             printf ("\tBufMemType = %d\n", denv->de_BufMemType);
  214.         }
  215.         if (denv->de_TableSize >= DE_MAXTRANSFER)
  216.         {
  217.             printf ("\tMaxTransfer = %d\n", denv->de_MaxTransfer);
  218.         }
  219.         if (denv->de_TableSize >= DE_MASK)
  220.         {
  221.             printf ("\tMask = %d\n", denv->de_Mask);
  222.         }
  223.         if (denv->de_TableSize >= DE_BOOTPRI)
  224.         {
  225.             printf ("\tBootPri = %d\n", denv->de_BootPri);
  226.         }
  227.         if (denv->de_TableSize >= DE_DOSTYPE)
  228.         {
  229.             printf ("\tDosType = 0x%X\n", denv->de_DosType);
  230.         }
  231.         if (denv->de_TableSize >= DE_BAUD)
  232.         {
  233.             printf ("\tBaud = %d\n", denv->de_Baud);
  234.         }
  235.         if (denv->de_TableSize >= DE_CONTROL)
  236.         {
  237.             printf ("\tControl = %d\n", denv->de_Control);
  238.         }
  239.         if (denv->de_TableSize >= DE_BOOTBLOCKS)
  240.         {
  241.             printf ("\tBootBlocks = %d\n", denv->de_BootBlocks);
  242.         }
  243.     }
  244.  
  245.     printf ("#\n");
  246.  
  247.     return;
  248. }
  249.  
  250. /* ------------------------------------------------------------------------    */
  251. void main (LONG argc, char *argv[])
  252. {
  253. struct DosList    *dosl;
  254.     if (argc != 2 || argv[1][0] == '?')
  255.     {
  256.         printf ("%s%s\n", version, createur);
  257.         printf (format, argv[0]);
  258.         return;
  259.     }
  260.  
  261.     DOSBase = (struct DosLibrary*)OpenLibrary ("dos.library", 0L);
  262.  
  263.     if (DOSBase)
  264.     {
  265.         dosl = ChercheDosList (argv[1], DLT_DEVICE);
  266.         if (dosl == NULL)
  267.             printf ("Handler \"%s:\" introuvable\n", argv[1]);
  268.         else
  269.             AfficheMountList (dosl);
  270.  
  271.         CloseLibrary (DOSBase);
  272.     }
  273.  
  274.     return;
  275. }
  276.